<?php

/* @var $this \yii\web\View */
/* @var $content string */

use yii\helpers\Html;
use yii\helpers\Url;

use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;
use app\models\MAbout;
use app\models\MGoodscat;
use app\models\MGoods;
use app\models\Category;

AppAsset::register($this);

$about = MAbout::find()->one();
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">

    <!--
    <meta name="viewport" content="width=device-width, initial-scale=1">
    -->

    <!-- Sets initial viewport load and disables zooming  -->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">

    <!-- Makes your prototype chrome-less once bookmarked to your phone's home screen -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">


    <!--
    <LINK href="favicon1.ico" type="image/x-icon" rel=icon>
    <LINK href="favicon1.ico" type="image/x-icon" rel="shortcut icon">
    -->
    <link rel="stylesheet" href="http://libs.useso.com/js/font-awesome/4.2.0/css/font-awesome.min.css">
    <?= Html::csrfMetaTags() ?>
    <title>武汉红松仪表租赁有限公司-管理后台</title>
    <?php $this->head() ?>
    
    <style type="text/css">

        .wrap > .container {
            width: 100%;
        }

        .footer {
            height: 60px;
            background-color: #f5f5f5;
            border-top: 1px solid #ddd;
            padding-top: 20px;
        }

        .bs-docs-sidenav > li:first-child > a {
            border: solid 1px #e5e5e5;
        }

        /* 回到顶部开始 */
        .back-to-top { position: fixed; bottom: 100px; right: 2px; padding: 3px 8px; font-size: 24px; color: #666; display: none; }
        /* 回到顶部结束 */
    </style>


    <style>

        /* Sidenav for Docs
        -------------------------------------------------- */

        .bs-docs-sidenav {

            margin: 30px 0 0;
            padding: 0;
            background-color: #fff;
            -webkit-border-radius: 6px;
            -moz-border-radius: 6px;
            border-radius: 6px;
            -webkit-box-shadow: 0 1px 4px rgba(0,0,0,.065);
            -moz-box-shadow: 0 1px 4px rgba(0,0,0,.065);
            box-shadow: 0 1px 4px rgba(0,0,0,.065);
        }
        .bs-docs-sidenav > li > a {
            display: block;

            margin: 0 0 -1px;
            padding: 8px 14px;
            border: 1px solid #e5e5e5;
        }
        .bs-docs-sidenav > li:first-child > a {
            -webkit-border-radius: 6px 6px 0 0;
            -moz-border-radius: 6px 6px 0 0;
            border-radius: 6px 6px 0 0;
        }
        .bs-docs-sidenav > li:last-child > a {
            -webkit-border-radius: 0 0 6px 6px;
            -moz-border-radius: 0 0 6px 6px;
            border-radius: 0 0 6px 6px;
        }
        .bs-docs-sidenav > .active > a {
            position: relative;
            z-index: 2;
            padding: 9px 15px;
            border: 0;
            text-shadow: 0 1px 0 rgba(0,0,0,.15);
            -webkit-box-shadow: inset 1px 0 0 rgba(0,0,0,.1), inset -1px 0 0 rgba(0,0,0,.1);
            -moz-box-shadow: inset 1px 0 0 rgba(0,0,0,.1), inset -1px 0 0 rgba(0,0,0,.1);
            box-shadow: inset 1px 0 0 rgba(0,0,0,.1), inset -1px 0 0 rgba(0,0,0,.1);
        }
        /* Chevrons */
        .bs-docs-sidenav .icon-chevron-right {
            float: right;
            margin-top: 2px;
            margin-right: -6px;
            opacity: .25;
        }
        .bs-docs-sidenav > li > a:hover {
            background-color: #f5f5f5;
        }
        .bs-docs-sidenav a:hover .icon-chevron-right {
            opacity: .5;
        }
        .bs-docs-sidenav .active .icon-chevron-right,
        .bs-docs-sidenav .active a:hover .icon-chevron-right {
            /*
            background-image: url(../img/glyphicons-halflings-white.png);
            */
            opacity: 1;
        }
        .bs-docs-sidenav.affix {
            top: 40px;
        }
        .bs-docs-sidenav.affix-bottom {
            position: absolute;
            top: auto;
            bottom: 270px;
        }

        /* Desktop
        ------------------------- */
        @media (max-width: 980px) {
            /* Unfloat brand */
            body > .navbar-fixed-top .brand {
                float: left;
                margin-left: 0;
                padding-left: 10px;
                padding-right: 10px;
            }

            /* Inline-block quick links for more spacing */
            .quick-links li {
                display: inline-block;
                margin: 5px;
            }

            /* When affixed, space properly */
            .bs-docs-sidenav {
                top: 0;
                margin-top: 30px;
                margin-right: 0;
            }
        }

        /* Tablet to desktop
        ------------------------- */
        @media (min-width: 768px) and (max-width: 979px) {
            /* Remove any padding from the body */
            body {
                padding-top: 0;
            }
            /* Widen masthead and social buttons to fill body padding */
            .jumbotron {
                margin-top: -20px; /* Offset bottom margin on .navbar */
            }
            /* Adjust sidenav width */
            .bs-docs-sidenav {
                margin-top: 20px;
            }
            .bs-docs-sidenav.affix {
                top: 0;
            }
        }

    </style>
</head>
<body>
<?php $this->beginBody() ?>

<div class="wrap">

        <?php
        if(Yii::$app->user->isGuest)
        {
            $isAdmin = false;
            $isMember = false;
        }
        else
        { 
            if (Yii::$app->user->identity->role == 1)
            {
                $isAdmin = true;
                $isMember = false;
                $flagLable = "&nbsp;<span style='font-size:14px; color: #FFFFFF; background:#777777; border:solid 1px #777777;-webkit-border-radius: 10px;border-radius: 10px;'>&nbsp;管理后台&nbsp;</span>";
            }
            else /*role == 0*/
            {
                $isAdmin = false;
                $isMember = true;
                $flagLable = "";
            }
        }

        //get goods cat
        //$goodscat = MGoodscat::find()->all();
        $goodscat = Category::find()->where(['parent_id' => 0])->all();

        $brandLabel = empty($about->com_name)?"":$about->com_name;
        $brandLabel = $brandLabel.$flagLable;
        NavBar::begin([
             //'brandLabel' => Html::img($asset->baseUrl . '/logo.png'),
            'brandLabel' => $brandLabel,
            'brandUrl' => Yii::$app->homeUrl,
            'options' => [
                'class' => 'navbar-inverse navbar-fixed-top',
            ],

        ]);

        foreach ($goodscat as $gc) {

            $goodsCnt = MGoods::find()->where(['status' => 1, 'goods_kind' => $gc->id])->count();

            if($goodsCnt == 0)
            {
                $menuItems[] = [
                    'label' => $gc->name.'&nbsp;<span>&nbsp;</span> ',
                    'url' => ['/site/client-goods-list','pub_userid'=>Yii::$app->user->isGuest?-1:Yii::$app->user->identity->id,'goods_kind'=>$gc->id],
                    'linkOptions' => ['data-method' => 'post']
                ];
            }
            else
            {
                $menuItems[] = [
                    'label' => $gc->name.'&nbsp;<span class="badge1">'.$goodsCnt.'</span> ',
                    'url' => ['/site/client-goods-list','pub_userid'=>Yii::$app->user->isGuest?-1:Yii::$app->user->identity->id,'goods_kind'=>$gc->id],
                    'linkOptions' => ['data-method' => 'post']
                ];
            }

        }

      
        echo Nav::widget([
            'options' => ['class' => 'navbar-nav navbar-right'],
            'encodeLabels' => false,
            //'items' => $menuItems,
            'items' => [

                //['label' => '<form class="navbar-form navbar-left" role="search"><div class="input-group"><input type="text" class="form-control" placeholder="Search"><span class="input-group-btn"><button class="btn btn-default" type="button"><span class="fa fa-search"></span></button></span></div></form>'],

                ['label' => '<i class="fa fa-dashboard"></i> 主面板', 'url' => ['/site/mainboard']],

                //['label' => '关于', 'url' => ['/site/about']],
                ($isAdmin)?"":
                [
                    'label' => '关于我们',
                    'items' => [
                        ['label' => '公司简介','url' => ['/site/about'],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '招贤纳士','url' => ['/site/client-hr-list','cat'=>7],'linkOptions' => ['data-method' => 'post']],
                        '<li class="divider"></li>',
                        ['label' => '意见反馈','url' => ['/site/contact'],'linkOptions' => ['data-method' => 'post']],
                    ]
                ],

                ($isAdmin)?"":
                [
                    'label' => '技术天地',
                    'items' => [
                        ['label' => '解决方案','url' => ['/site/client-tech-list','cat'=>4],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '产品学习','url' => ['/site/client-tech-list','cat'=>5],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '技术文章','url' => ['/site/client-tech-list','cat'=>6],'linkOptions' => ['data-method' => 'post']],
                    ]
                ],


                //['label' => '联系', 'url' => ['/site/contact']],
                //['label' => '商品列表', 'url' => ['/site/client-goods-list']],

                ($isAdmin)?"":
                [
                    'label' => '商品列表',
                    'items' => $menuItems,
                ],


                ($isAdmin)?"":
                [
                    'label' => '新闻动态',
                    'items' => [
                        ['label' => '行业新闻','url' => ['/site/client-news-list','cat'=>1],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '公司动态','url' => ['/site/client-news-list','cat'=>2],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '展会信息','url' => ['/site/client-news-list','cat'=>3],'linkOptions' => ['data-method' => 'post']],
                    ]
                ], 


                [
                    'label' => '会员',
                    'visible' => $isMember,
                    'items' => [
                        ['label' => '<i class="fa fa-tags"></i> 商品管理','url' => ['/goods/index','pub_userid'=>Yii::$app->user->identity->id, 'goods_kind' => 0],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '<i class="fa fa-shopping-cart"></i> 我的订单','url' => ['/order/index','userid'=>Yii::$app->user->identity->id],'linkOptions' => ['data-method' => 'post']],
                        '<li class="divider"></li>',
                        ['label' => '<i class="fa fa-user"></i> 会员信息','url' => ['/site/client-user-view','id'=>Yii::$app->user->identity->id],'linkOptions' => ['data-method' => 'post']],

                    ]
                ],   

                [
                    'label' => '管理',
                    'visible' => $isAdmin,
                    'items' => [
                        ['label' => '<i class="fa fa-dashboard"></i> 主面板','url' => ['/site/mainboard'],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '<i class="fa fa-user"></i> 用户管理','url' => ['/user/index'],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '<i class="fa fa-tags"></i> 商品管理','url' => ['/goods/index','pub_userid'=>Yii::$app->user->identity->id, 'goods_kind' => 0],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '<i class="fa fa-shopping-cart"></i> 订单管理','url' => ['/order/index','userid'=>Yii::$app->user->identity->id],'linkOptions' => ['data-method' => 'post']],
                        '<li class="divider"></li>',
                        ['label' => '<i class="fa fa-reorder"></i> 商品分类管理','url' => ['/category/index'],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '<i class="fa fa-reorder"></i> 商品品牌管理','url' => ['/brand/index'],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '<i class="fa fa-picture-o"></i>  轮播图管理','url' => ['/carousel/index'],'linkOptions' => ['data-method' => 'post']],
                        '<li class="divider"></li>',
                        ['label' => '<i class="fa fa-newspaper-o"></i> 文章管理','url' => ['/news/index', 'cat' => 0],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '<i class="fa fa-sitemap"></i> 公司信息设置','url' => ['/about/index'],'linkOptions' => ['data-method' => 'post']],
                        ['label' => '<i class="fa fa-cog"></i> 网站全局配置','url' => ['/keywords/index'],'linkOptions' => ['data-method' => 'post']],
                        '<li class="divider"></li>',
                        ['label' => '<i class="fa fa-envelope"></i> 用户反馈','url' => ['/suggest/index'],'linkOptions' => ['data-method' => 'post']],

                    ]
                ],      

                Yii::$app->user->isGuest?
                ['label' => '登录', 'url' => ['/site/login']]:
                [
                    'label' => '<span class="glyphicon glyphicon-user"></span> '.Html::encode(Yii::$app->user->identity->username),
                    'items' => [
                        //['label' => '修改设置','url' => ['/site/profile'],'linkOptions' => ['data-method' => 'post']],
                        //'<li class="divider"></li>',
                        ['label' => '<i class="fa  fa-sign-out"></i> 退出','url' => ['/site/logout'],'linkOptions' => ['data-method' => 'post']],
                    ]
                ],

            ],
        ]);
        NavBar::end();
    ?>



    <div class="container">
        <!-- 管理员 Breadcrumbs -->
        <?= Breadcrumbs::widget([
            'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
            'homeLink' => [
                'label' => '管理后台',  // required
                'url' => Url::to(['site/mainboard']),
            ],
        ]) ?>


        <div class="row">

            <div class="col-md-2" id="admin_menu">
                <ul id="w3" class="nav nav-list bs-docs-sidenav pinned">

                    <li class="active"><a href="/index.php?r=site/mainboard" data-method="post" tabindex="-1"><i class="fa fa-dashboard"></i> 主面板</a></li>
                    <li><a href="/index.php?r=user/index" data-method="post" tabindex="-1"><i class="fa fa-user"></i> 用户管理</a></li>
                    <li><a href="/index.php?r=goods/index&amp;pub_userid=4&amp;goods_kind=0" data-method="post" tabindex="-1"><i class="fa fa-tags"></i> 商品管理</a></li>
                    <li><a href="/index.php?r=order/index&amp;userid=4" data-method="post" tabindex="-1"><i class="fa fa-shopping-cart"></i> 订单管理</a></li>
                    <li class="divider"></li>
                    <li><a href="/index.php?r=category/index" data-method="post" tabindex="-1"><i class="fa fa-reorder"></i> 商品分类管理</a></li>
                    <li><a href="/index.php?r=brand/index" data-method="post" tabindex="-1"><i class="fa fa-reorder"></i> 商品品牌管理</a></li>
                   <li><a href="/index.php?r=carousel/index" data-method="post" tabindex="-1"><i class="fa fa-picture-o"></i> 轮播图管理</a></li>
                    <li class="divider"></li>
                    <li><a href="/index.php?r=news/index&amp;cat=0" data-method="post" tabindex="-1"><i class="fa fa-newspaper-o"></i> 文章管理</a></li>
                    <li><a href="/index.php?r=about/index" data-method="post" tabindex="-1"><i class="fa fa-sitemap"></i> 公司信息设置</a></li>
                    <li><a href="/index.php?r=keywords/index" data-method="post" tabindex="-1"><i class="fa fa-cog"></i> 网站全局配置</a></li>
                    <li class="divider"></li>
                    <li><a href="/index.php?r=suggest/index" data-method="post" tabindex="-1"><i class="fa fa-envelope"></i> 用户反馈</a></li>
                </ul>
            </div>

            <div class="col-md-10" id="admin_content">
                <?= $content ?>
            </div>
        </div>

    </div>

     <a class="back-to-top btn btn-default"><span class="fa fa-arrow-up"></span></a>
</div>

<footer class="footer">
    <div class="container">

        <p align="center">
            <span class="glyphicon glyphicon-globe"></span>
            <?= empty($about->com_name)?"":$about->com_name ?>&copy; <?= date('Y') ?>
            <br>
            <a href="#" id="hide_show_menu"><<隐藏&nbsp;&nbsp;显示>>左侧菜单</a>
        </p>
		<!--
        <p class="pull-right"><//?= Yii::powered() ?></p>
		-->

    </div>
</footer>


<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>

<script type="text/javascript">
    //localStorage.setItem("hs_menu_status","show");

    function shMenu()
    {
        if(localStorage.getItem("hs_menu_status") == "hide")
        {
            $("#admin_menu").removeClass();
            $("#admin_menu").addClass("col-md-2 hidden");

            $("#admin_content").removeClass();
            $("#admin_content").addClass("col-md-12");
        }
        else
        {
            $("#admin_menu").removeClass();
            $("#admin_menu").addClass("col-md-2");

            $("#admin_content").removeClass();
            $("#admin_content").addClass("col-md-10");
        }
    }

    $(document).ready(function () {
        shMenu();

        $("#hide_show_menu").click(
            function(){
                if(localStorage.getItem("hs_menu_status") == "show")
                {
                    localStorage.setItem("hs_menu_status", "hide");
                }
                else
                {
                    localStorage.setItem("hs_menu_status", "show");
                }

                shMenu();

            });
        //alert("loaded!");
            // back-to-top
        $(window).scroll(function(){
            if ($(this).scrollTop() > 500) {
                $('.back-to-top').fadeIn();
            } else {
                $('.back-to-top').fadeOut();
            }
        });
        $(".back-to-top").click(function(e) {
            e.preventDefault();
            $("html, body").animate({ scrollTop: 0 }, "slow");
        });




    });


</script>
<!-- Include jQuery and jquery.pin -->
<script src="/jquery.pin/jquery.pin.min.js"></script>


<!-- PIN ALL THE THINGS! -->
<script>
    $(".pinned").pin({containerSelector: ".container", minWidth: 940});
</script>